package cn.itcast.bos.dao.base;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import cn.itcast.bos.domain.base.Courier;

public interface CourierDao extends JpaRepository<Courier, Integer>,JpaSpecificationExecutor<Courier> {
	
	//逻辑删除--将deltag值改为1
	@Query("update Courier set deltag='1' where id=?")
	@Modifying
	void logicDelete(int courierId);
	
	/*select * from t_courier t1 where t1.c_deltag='0' and t1.c_id not in(
			select c.c_id from t_courier c,t_fixedarea_courier fc,t_fixed_area f
			where fc.c_courier_id=c.c_id and fc.c_fixed_area_id=f.c_id
			and f.c_id='DQ12332'
			)*/
	@Query("from Courier c1 where c1.deltag='0' and c1.id not in(select c.id from Courier c inner join c.fixedAreas f where f.id=?)")
	List<Courier> findNotDeleteAndNotAssocation(String fixedAreaId);

	
	@Query("update Courier set deltag='0' where id=?")
	@Modifying
	void restore(int parseInt);

}
